<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
<h1>首页</h1>
<form method="post" th:action="@{/resp/testRequestBody}">
    <input name="username" type="text">
    <input name="password" type="text">
    <input type="submit" value="测试@RequestBody">
</form>
<form method="post" th:action="@{/resp/testRequestEntity}">
    <input name="username" type="text">
    <input name="password" type="text">
    <input type="submit" value="测试RequestEntity">
</form>
<a th:href="@{/resp/testResponse}">通过servletAPI的response对象响应浏览器数据</a><br>
<a th:href="@{/resp/testResponseBody}">通过@ResponseBody响应浏览器数据</a><br>
<a th:href="@{/resp/testResponseUser}">通过@ResponseBody响应浏览器User对象</a><br>
<div id="app">
    <a @click="testAxios" th:href="@{/resp/testAxios}">SpringMVC处理ajax</a>
</div>
<!--webapp下-->
<script th:src="@{/static/js/vue.js}" type="text/javascript"></script>
<script th:src="@{/static/js/axios.min.js}" type="text/javascript"></script>
<script type="text/javascript">
    new Vue({
        el: "#app",
        methods: {
            testAxios: function (event) {
                axios({
                    method: "post",
                    url: event.target.href,
                    params: {
                        username: "admin",
                        password: "123456"
                    }
                }).then(function (response) {
                    alert(response.data);
                });
                //no跳转
                event.preventDefault();
            }
        }
    });
</script>
</body>
</html>